'''
A move of a piece.
'''

from pygo1963.model import Constants

class Move:
    """ A move of a Go piece. Pass is not a valid move. """    
    
    def __init__(self, color, vertex):
        """
        Creates a Move of a piece of the given color, on the
        specified board vertex.
        """
        
        color = color.strip().lower()        
        if color == 'w' or color == 'white':
            self.color = Constants.WHITE_COLOR        
        elif color == 'b' or color == 'black':
            self.color = Constants.BLACK_COLOR
        else: 
            raise InvalidColorError()
        
        self.vertex = vertex
    
    def __str__(self):
        return '%s %s' % (self.color, self.vertex)
    
    def __eq__(self, other):
        return self.color == other.color and self.vertex == other.vertex
        
    def __repr__(self):
        return self.__str__()

class InvalidColorError(Exception):
    pass